import request from '@/utils/request'

const marketSubscribeApi = {
    /**
     * 订阅售价列表
     */
    pricing(user_id: number, calendar: string): Promise<any> {
        return request.get({
            url: '/market/subscribe/pricing',
            params: {
                user_id: user_id,
                calendar: calendar
            }
        })
    },

    /**
     * 订阅套餐列表
     */
    lists(): Promise<any> {
        return request.get({
            url: '/market/subscribe/lists'
        })
    },

    /**
     * 订阅套餐详情
     */
    detail(id: number): Promise<any> {
        return request.get({
            url: '/market/subscribe/detail',
            params: { id }
        })
    },

    /**
     * 订阅套餐模型
     */
    models(): Promise<any> {
        return request.get({
            url: '/market/subscribe/models'
        })
    },

    /**
     * 订阅套餐新增
     */
    add(params: {
        name: string;
        description?: string;
        train_num?: number;
        robot_num?: number;
        know_num?: number;
        mcp_num?: number;
        sort?: number;
        is_disable?: number;
        pricing_list?: any[];
        specific_list?: any[];
        apply_list?: any[];
    }): Promise<any> {
        return request.post({
            url: '/market/subscribe/add',
            params
        })
    },

    /**
     * 订阅套餐编辑
     */
    edit(params: {
        id: number;
        name: string;
        description?: string;
        train_num?: number;
        robot_num?: number;
        know_num?: number;
        mcp_num?: number;
        sort?: number;
        is_disable?: number;
        pricing_list?: any[];
        specific_list?: any[];
        apply_list?: any[];
    }): Promise<any> {
        return request.post({
            url: '/market/subscribe/edit',
            params
        })
    },

    /**
     * 订阅套餐删除
     */
    delete(id: number): Promise<any> {
        return request.post({
            url: '/market/subscribe/delete',
            params: { id }
        })
    },

    /**
     * 订阅配置读取
     */
    getConfig(): Promise<any> {
        return request.get({
            url: '/market/subscribe/get_config'
        })
    },

    /**
     * 订阅配置修改
     */
    setConfig(params: {
        status: number;
        timeline: any;
    }): Promise<any> {
        return request.post({
            url: '/market/subscribe/set_config',
            params
        })
    },

    /**
     * 订阅套餐开通
     */
    open(params: {
        user_id: number;
        pricing_id: number;
        paid_amount: number;
    }): Promise<any> {
        return request.post({
            url: '/market/subscribe/open_vip',
            params
        })
    }
}

export default marketSubscribeApi
